package com.itfreer.arcgis.symbol;

import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.SimpleRenderer;
import com.esri.arcgisruntime.symbology.Symbol;

/**
 * arcgis 符号操作
 */
public class SymbolUtils
{
    /**
    * 获取点样式
    */
    public static SimpleMarkerSymbol GetPointSymbol(SymbolStyleType.PointType pointType, int color, float size)
    {
        return new SimpleMarkerSymbol(getPointSymbolStyle(pointType),color,size);
    }

    /**
     * 点类型转换
     * @param pointType
     * @return
     */
    private static  SimpleMarkerSymbol.Style getPointSymbolStyle(SymbolStyleType.PointType pointType)
    {
        switch (pointType)
        {
            case CIRCLE:
                return  SimpleMarkerSymbol.Style.CIRCLE;
            case SQUARE:
                return  SimpleMarkerSymbol.Style.SQUARE;
            case TRIANGLE:
                return  SimpleMarkerSymbol.Style.TRIANGLE;
            case X:
                return  SimpleMarkerSymbol.Style.X;
            case CROSS:
                return  SimpleMarkerSymbol.Style.CROSS;
            case DIAMOND:
                return  SimpleMarkerSymbol.Style.DIAMOND;
        }
        return  SimpleMarkerSymbol.Style.CIRCLE;
    }

    /**
     * 获取线样式
     */
    public static SimpleLineSymbol GetPolylineSymbol(SymbolStyleType.PolylineType polylineType, int color, float size)
    {
        return new SimpleLineSymbol(getLineSymbolStyle(polylineType),color,size);
    }

    /**
     * 线类型转换
     * @param polylineType
     * @return
     */
    private static   SimpleLineSymbol.Style getLineSymbolStyle(SymbolStyleType.PolylineType polylineType)
    {
        switch (polylineType)
        {
            case DASH:
                return  SimpleLineSymbol.Style.DASH;
            case DASH_DOT:
                return  SimpleLineSymbol.Style.DASH_DOT;
            case DASH_DOT_DOT:
                return  SimpleLineSymbol.Style.DASH_DOT_DOT;
            case DOT:
                return  SimpleLineSymbol.Style.DOT;
            case SOLID:
                return  SimpleLineSymbol.Style.SOLID;
            case NULL:
                return  SimpleLineSymbol.Style.NULL;
        }
        return  SimpleLineSymbol.Style.NULL;
    }

    /**
     * 面类型转换
     * @param polygonType
     * @return
     */
    private static   SimpleFillSymbol.Style getPolygonSymbolStyle(SymbolStyleType.PolygonType polygonType)
    {
        switch (polygonType)
        {
            case BACKWARD_DIAGONAL:
                return  SimpleFillSymbol.Style.BACKWARD_DIAGONAL;
            case CROSS:
                return  SimpleFillSymbol.Style.CROSS;
            case FORWARD_DIAGONAL:
                return  SimpleFillSymbol.Style.FORWARD_DIAGONAL;
            case HORIZONTAL:
                return  SimpleFillSymbol.Style.HORIZONTAL;
            case NULL:
                return  SimpleFillSymbol.Style.NULL;
            case SOLID:
                return  SimpleFillSymbol.Style.SOLID;
            case VERTICAL:
                return  SimpleFillSymbol.Style.VERTICAL;
            case DIAGONAL_CROSS:
                return  SimpleFillSymbol.Style.DIAGONAL_CROSS;
        }
        return  SimpleFillSymbol.Style.NULL;
    }

    /**
     * 获取面样式
     */
    public static SimpleFillSymbol GetPolygonSymbol(SymbolStyleType.PolygonType polygonType, int color, SimpleLineSymbol outLineSymbol)
    {
        return new SimpleFillSymbol(getPolygonSymbolStyle(polygonType), color, outLineSymbol);
    }

    public static SimpleRenderer GetRenderer(Symbol symbol)
    {
        return  new SimpleRenderer(symbol);
    }
}
